import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Login',
    component:Login
    // component: ()=>import('../views/Login.vue')
  },
  // {
  //   path: '/',
  //     name: 'Login',
  //     component:()=>import('../views/Login.vue')
  // },
  {
    path: '/register',
    name: '注册',
    component: () => import('../views/Register.vue')
  },
  {
    path:'/home',
    name:"首页",
    component:()=>import('../views/Home.vue')
  },
  {
    path:'/addShop',
    name:"添加商铺",
    component:()=>import('../views/addShop.vue')
  },
  {
    path:"/addFood",
    name:"添加食品",
    component:()=>import('../views/addFood.vue')
  },
  {
    path:'/shopList',
    name:'商铺列表',
    component:()=>import('../views/ShopList.vue')
  },
  {
    path:'/admin',
    name:'管理员列表',
    component:()=>import('../views/adminList.vue')
  },
  {
    path:"/foodList",
    name:"食物列表",
    component:()=>import('../views/FoodList.vue')
  },
  {
    path:'/userSetting',
    name:'用户设置',
    component:()=>import('../views/userSetting.vue')
  },
  {
    path:'/userFenbu',
    name:"用户分布",
    component:()=>import("../views/userFenbu.vue")
  },
  {
    path:'/dDList',
    name:'订单列表',
    component:()=>import('../views/dDList.vue')
  },
  {
    path:'/userList',
    name:'用户列表',
    component:()=>import('../views/userList.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
//自己页面跳自己页面报错问题
const originalPush=VueRouter.prototype.push;
VueRouter.prototype.push=function push(location){
  return originalPush.call(this,location).catch(err=>err)
}

// router.beforeEach((to,from,next)=>{
//   console.log(to,from)
//   if(to.path==from.path){
//     console.log("kdf")
//     next(to.path)
  
//   }else{
//          next()
//   }
  
// })

export default router
